#ifndef LOCALDB_H
#define LOCALDB_H

#include <QObject>
#include <QSqlDatabase>
#include <QJsonObject>
#include <QJsonArray>
#include <QMutex>

class LocalDb : public QObject
{
    Q_OBJECT

public:
    QMutex m_mutex;

public:
    explicit LocalDb(QObject *parent = nullptr);

public:
    bool Open(QString path);
    QJsonObject ReadShopInfo();
    bool SaveShopInfo(QJsonObject data);

    bool SaveRecords(QJsonArray list);
    QJsonArray ReadRecords(QString shopCode);

    bool RemoveRecords(QJsonArray list);

private:
    QSqlDatabase db;

    QString generateUpdateClause(const QStringList &fields);

signals:
};

#endif // LOCALDB_H
